<!DOCTYPE html>
<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8"/>
    <title>学校管理</title>
    <link rel="stylesheet" th:href="@{/css/bootstrap.css}" />
    <link rel="stylesheet" th:href="@{/js/lib/layui/css/layui.css}" id="layuicss"/>
    <link rel="stylesheet" th:href="@{/css/basic.css}" />
    <link rel="stylesheet" th:href="@{/css/basic_pre.css}" />
    <script th:src="@{/js/lib/jquery.1.8.js}"></script>
</head>
<body>
    <nav th:replace="fragment/menu :: nav-top"></nav>

    <div class="container-fluid" id="app">
        <div class="row">
            <div th:replace="fragment/menu::menu"></div>
            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main ">
                <div style="margin:20px;">
                    <div class="sub-header">
                        <h2 class="sub-header-title" v-text="PageObj.title">学校管理</h2>
                        <div class="sub-header-nav">
                            <ul class="nav navbar-nav navbar-right">
                                <li><a href="#" class="btn-addItem" v-on:click="addItem()">从Excel导入</a></li>
                                <li><a href="#" class="btn-addItem" v-on:click="addItem()">新增</a></li>
                            </ul>
                            <div class="navbar-form navbar-right">
                                <input id="search_input" name="search_input" type="text" class="form-control" placeholder="Search..." v-on:change="search(search_input.value);"/>
                            </div>
                        </div>
                    </div>
                    <div class="panel-body" style="display:none;"></div>
                    <data-table :columns="columns" :items="items"></data-table>
                    <page-navigation :pageinfo="items.pageInfo"></page-navigation>
                    <div-additem :columns="columns" ref="editform_div"></div-additem>
                </div>
            </div>
        </div>
    </div>

    <script th:replace="fragment/template4vue :: data-table" type="text/x-template"></script>
    <script th:replace="fragment/template4vue :: page-navigation" type="text/x-template"></script>
    <script th:replace="fragment/template4vue :: div-additem" type="text/x-template"></script>
    
    <script th:inline="javascript">
    /*<![CDATA[*/
        var userId = [[${session.userSessionId}]];

        console.log([[@{/}]]);
    
        // changeSets: 取值表的别名(在dbapi中定义),查询字段名,返回值的字段名,要填充的input名(如果没有则和返回字段名一致)
        // dbDropDown: 取值表的别名(在dbapi中定义),过滤条件,值字段,文本字段; 只在SELECT中生效
        // ddList: 为指定的列生成下拉列表,由v-on:change事件触发,对应的列要有dbDropDown属性
        var PageObj = {
            contextPath: $("#contextPath").attr("href") ? $("#contextPath").attr("href") : "",
            title: "学校管理",
            dataUrl: $("#contextPath").attr("href") + "/data/schools?page=1&orderBy=-create_time,schoolname",
            columns: {
                "uuid": {
                    "title":"UUID",
                    "type":"hidden",
                },
                "schoolname": {
                    "title":"学校名称",
                    "validator":"required"
                },
                "schoolnick": {
                    "title":"学校简称",
                },
                "schooladdr": {
                    "title":"学校地址",
                    "validator":"unique:schools?whr-schooladdr",
                },
                //"englishName": {
                //    "title":"英文名称",
                //},
                "phone": {
                    "title":"联系电话",
                    "validator":"mobile",
                },
                "email": {
                    "title":"联系邮箱",
                    "type":"email",
                    "validator":"required|email"
                },
                "create_time": {
                    "title":"创建时间", 
                    "type":"hidden",
                },
                "status": {
                    "title":"当前状态",
                    "type": "select",
                    "options":{"0":"停用", "1":"启用"},
                    "default":"1"
                },
                "create_user": {
                    "title":"创建者ID",
                    "type":"hidden",
                    "default":userId
                },
            },
            items: "",
        };
    /*]]>*/
    </script>

    <script th:src="@{/js/require.js}" defer="true" async="true" data-main="./js/pages/PageCommon"></script>
</body>
</html>